<template>
    <div>
        <el-timeline>
            <el-timeline-item timestamp="2018/4/12" placement="top">
                <el-card>
                    <h4>更新 Github 模板</h4>
                    <p>王小虎 提交于 2018/4/12 20:46</p>
                </el-card>
            </el-timeline-item>
            <el-timeline-item timestamp="2018/4/3" placement="top">
                <el-card>
                    <h4>更新 Github 模板</h4>
                    <p>王小虎 提交于 2018/4/3 20:46</p>
                </el-card>
            </el-timeline-item>
            <el-timeline-item timestamp="2018/4/2" placement="top">
                <el-card>
                    <h4>更新 Github 模板</h4>
                    <p>王小虎 提交于 2018/4/2 20:46</p>
                </el-card>
            </el-timeline-item>
        </el-timeline>
    </div>
</template>

<script>
    export default {
        name: "message",
        data() {
            return {
                msg:{}
            }
        },
        created() {
            this.loadList();
        },
        methods: {
            loadList() {
                this.$axios.get('/api/message?size=1000', {headers: {TOKEN:localStorage.getItem('TOKEN')}}).then(res => {
                    if (res.data.status === 200) {
                        this.msgList = res.data.data.records;
                    } else {
                        this.$message.error(res.data.message);
                    }
                })
            },
            commit() {
                this.$axios.post('/api/message', this.msg, {headers: {TOKEN: localStorage.getItem('TOKEN')}}).then(res => {
                    if (res.data.status === 201) {
                        this.$message.success('发表成功');
                        this.loadList();
                    } else {
                        this.$message.error(res.data.message);
                    }

                })
            }
        }
    }
</script>

<style lang="scss" scoped>

</style>